package com.ruoyi.project.infoprojecttargetmidindex.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.infoprojecttargetmidindex.domain.InfoProjectTargetMidIndex;
import com.ruoyi.project.infoprojecttargetmidindex.service.IInfoProjectTargetMidIndexService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目目标填报—中的中期指标Controller
 * 
 * @author ruoyi
 * @date 2023-01-10
 */
@RestController
@RequestMapping("/infoprojectmidindex/infoprojectmidindex")
public class InfoProjectTargetMidIndexController extends BaseController
{
    @Autowired
    private IInfoProjectTargetMidIndexService infoProjectTargetMidIndexService;

    /**
     * 查询项目目标填报—中的中期指标列表
     */
    @PreAuthorize("@ss.hasPermi('infoprojectmidindex:infoprojectmidindex:list')")
    @GetMapping("/list")
    public TableDataInfo list(InfoProjectTargetMidIndex infoProjectTargetMidIndex)
    {
        startPage();
        List<InfoProjectTargetMidIndex> list = infoProjectTargetMidIndexService.selectInfoProjectTargetMidIndexList(infoProjectTargetMidIndex);
        return getDataTable(list);
    }

    /**
     * 导出项目目标填报—中的中期指标列表
     */
    @PreAuthorize("@ss.hasPermi('infoprojectmidindex:infoprojectmidindex:export')")
    @Log(title = "项目目标填报—中的中期指标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoProjectTargetMidIndex infoProjectTargetMidIndex)
    {
        List<InfoProjectTargetMidIndex> list = infoProjectTargetMidIndexService.selectInfoProjectTargetMidIndexList(infoProjectTargetMidIndex);
        ExcelUtil<InfoProjectTargetMidIndex> util = new ExcelUtil<InfoProjectTargetMidIndex>(InfoProjectTargetMidIndex.class);
        util.exportExcel(response, list, "项目目标填报—中的中期指标数据");
    }

    /**
     * 获取项目目标填报—中的中期指标详细信息
     */
    @PreAuthorize("@ss.hasPermi('infoprojectmidindex:infoprojectmidindex:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(infoProjectTargetMidIndexService.selectInfoProjectTargetMidIndexById(id));
    }

    /**
     * 新增项目目标填报—中的中期指标
     */
    @PreAuthorize("@ss.hasPermi('infoprojectmidindex:infoprojectmidindex:add')")
    @Log(title = "项目目标填报—中的中期指标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfoProjectTargetMidIndex infoProjectTargetMidIndex)
    {
        return toAjax(infoProjectTargetMidIndexService.insertInfoProjectTargetMidIndex(infoProjectTargetMidIndex));
    }

    /**
     * 修改项目目标填报—中的中期指标
     */
    @PreAuthorize("@ss.hasPermi('infoprojectmidindex:infoprojectmidindex:edit')")
    @Log(title = "项目目标填报—中的中期指标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InfoProjectTargetMidIndex infoProjectTargetMidIndex)
    {
        return toAjax(infoProjectTargetMidIndexService.updateInfoProjectTargetMidIndex(infoProjectTargetMidIndex));
    }

    /**
     * 删除项目目标填报—中的中期指标
     */
    @PreAuthorize("@ss.hasPermi('infoprojectmidindex:infoprojectmidindex:remove')")
    @Log(title = "项目目标填报—中的中期指标", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(infoProjectTargetMidIndexService.deleteInfoProjectTargetMidIndexByIds(ids));
    }
}
